{{ header }}{{ column_left }}
<div id="content">
    <div class="page-header">
		<div class="container-fluid">
		  	<div class="pull-left">
			  	<h1>{{ text_edit }}</h1>
			  	<ul class="breadcrumb">
					{% for breadcrumb in breadcrumbs %}
						<li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
					{% endfor %}
			  	</ul>
			</div>
	  	</div>
	</div>
    <div class="container-fluid" id="megamenu">
    	{% if error_warning %}
	    	<div class="alert alert-danger">{{ error_warning }}</div>
	    {% elseif success %}
	    	<div class="alert alert-success">{{ success }}</div>
	    {% endif %}

	    <div class="panel panel-default">
			<form action="{{ action }}" method="post" enctype="multipart/form-data" id="form">
				<div class="panel-body">
					<div class="rows">
						<ul class="nav nav-tabs" role="tablist">
							<li {% if selectedid ==0 %}class="active" {% endif %}> <a href="{{ link_add }}"> <span class="fa fa-plus"></span>{{ button_add_module }}</a></li>
							{% set i = 1 %}
							{% for key, module in moduletabs %}
								<li role="presentation" {% if module.module_id == selectedid %} class="active" {% endif %}>
								<a href="{{ link_add }}&module_id={{ module.module_id }}" aria-controls="bannermodule-{{ key }}"  >
									<span class="fa fa-pencil"></span> {{ module.name }}
								</a>
								</li>
								{% set i = i + 1 %}
							{% endfor %}
						</ul>
					</div>

					<div class="rows megacontent">
						<div class="col-md-12 col-xs-12 col-sm-12">
							<div class="background clearfix">
								{% if moduleid %}
									<div class="left col-md-4 col-xs-12 col-sm-6 ">
										<a href="{{ action }}&action=create" class="btn btn-primary" > {{ text_creat_new_item }}</a>

										<a id="nestable-menu">
												<button type="button" data-action="expand-all" class="btn btn-primary">{{ text_expand_all }}</button>
												<button type="button" data-action="collapse-all" class="btn btn-primary">{{ text_collapse_all }}</button>
										</a>
										{{ nestable_list }}
										<div id='sortDBfeedback' style="padding: 10px 0px 0px 0px"></div>
									</div>
								{% endif %}

								{% if action_type == 'create' or action_type == 'edit' %}
									<div class="right col-md-8 col-xs-12 col-sm-6">
										<div class="buttons clearfix">
											<button type="submit" name="button-back" class="button-save" value="" title="Configuration"><i class="fa fa-cog"></i></button>
											{% if action_type == 'create' %}
												<button type="submit" name="button-create" class="button-save" value="" title="Save"><i class="fa fa-floppy-o"></i></button>
											{% elseif action_type == 'edit' %}
												<button type="submit" name="button-edit" class="button-save" value="" title="Save"><i class="fa fa-floppy-o"></i></button>
											{% else %}
												<button type="submit" name="button-save" class="button-save" value="" title="Save"><i class="fa fa-floppy-o"></i></button>
											{% endif %}
										</div>
										{% if action_type == 'edit' %}
											<h4>{{ text_edit_item }} {{ edit }}</h4>
											<input type="hidden" name="id" value="{{ edit }}" />
										{% else %}
											<h4>{{ text_creat_new_item }}</h4>
										{% endif %}
										<div class="input clearfix">
											<p>{{ text_name }}</p>
											{% set i = 0 %}
											{% for language  in languages %}
											{% set i = i + 1 %}
											 	<input type="text" name="name[{{ language.language_id }}]" placeholder="{{ entry_description_name }}" id="input-head-name-{{ language.language_id }}" value="{{ name[language.language_id] ? name[language.language_id] : '' }}" class="form-control {{ i>1 ? ' hide ' : ' first-name' }}" />
											{% endfor %}
											<select  class="form-control" id="language">
												{% for language in languages %}
													<option value="{{ language.language_id }}"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}"> {{ language.name }}</option>
												{% endfor %}
											</select>
										</div>
										<div class="input clearfix">
											<p>{{ text_class_menu }}</p>
											<div class="list-language">
												<input type="text" name="class_menu" value="{{ class_menu }}">
											</div>
										</div>
										
										<h4 class="button_parent_config">{{ text_parent_config }}</h4>({{ text_parent_item }})
										<div id="text_parent_config" class="collapse">									
											<div class="input clearfix">
												<p>{{ text_description }}</p>
												{% set i = 0 %}
												{% for language in languages %}
												{% set i = i + 1 %}
												 	<input type="text" name="description[{{ language.language_id }}]" placeholder="{{ entry_description_name }}" id="input-head-des-{{ language.language_id }}" value="{{ description[language.language_id] ? description[language.language_id] : '' }}" class="form-control {{ i>1 ? ' hide ' : ' first-name' }}" />
												{% endfor %}
												<select  class="form-control" id="des_language">
												  	{% for language in languages %}
														<option value="{{ language.language_id }}"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}"> {{ language.name }}</option>
													{% endfor %}
												</select>
											</div>
									
											<div class="input clearfix">
												<p>{{ "Icon Thumb" }}</p>
												<a href="" id="thumb-image" data-toggle="image" class="img-thumbnail"><img src="{{ src_icon }}" alt="" title="" data-placeholder="{{ placeholder }}"  /></a>
												<input type="hidden" name="icon" value="{{ icon }}" id="input-image" />
											</div>

											<div class="input clearfix">
												<p>{{ text_label_item }}</p>
												<div class="list-language">
														<input type="text" name="label_item" value="{{ label_item }}">
												</div>
											</div>

											<div class="input clearfix">
												<p>{{ text_icon_font }}</p>
												<div class="list-language">
													<input type="text" name="icon_font" value="{{ icon_font }}">
												</div>
											</div>

											<div class="input clearfix">
												<p>{{ text_type_link }}</p>
												<select name="type_link" class="type_link">
													{% if type_link == 1 %}
														<option value="0">Url</option>
														<option value="1" selected="selected">Category</option>
													{% else %}
														<option value="0" selected="selected">Url</option>
														<option value="1">Category</option>
													{% endif %}
												</select>
											</div>
										
											<div class="input  type_link_url clearfix " {% if type_link == 1 %} {{ 'style="display:none"' }} {% endif %}>
												<p>Url</p>
												<input type="text" value="{{ link.url }}" name="link[url]">
											</div>
										
											<div class="input type_link_category clearfix" {% if type_link != 1 %} {{ 'style="display:none"' }} {% endif %}>
												<p>{{ text_categories }}</p>
												<select name="link[category]">
												  	<option value="">{{ text_all_categories }}</option>
												  	{% for category in categories %}
												  		<option value="{{ category.category_id }}" {% if link.category == category.category_id %} {{ 'selected' }} {% endif %}>{{ category.name }}</option>
												  	{% endfor %}
												</select>
											</div>
										
											<div class="input clearfix">
												<p>{{ text_link_in_new_window }}</p>
												<select name="new_window">
													{% if new_window == 1 %}
														<option value="0">{{ text_disabled }}</option>
														<option value="1" selected="selected">{{ text_enabled }}</option>
													{% else %}
														<option value="0" selected="selected">{{ text_disabled }}</option>
														<option value="1">{{ text_enabled }}</option>
													{% endif %}
												</select>
											</div>
										
											<div class="input clearfix">
												<p>{{ text_status }}</p>
												<select name="status">
													{% if status == 1 %}
														<option value="0">{{ text_enabled }}</option>
														<option value="1" selected="selected">{{ text_disabled }}</option>
													{% else %}
														<option value="0" selected="selected">{{ text_enabled }}</option>
														<option value="1">{{ text_disabled }}</option>
													{% endif %}
												</select>
											</div>

											<div class="input clearfix">
												<p>{{ text_position }}</p>
												<select name="position">
													{% if position == 1 %}
														<option value="0">{{ text_left }}</option>
														<option value="1" selected="selected">{{ text_right }}</option>
													{% else %}
														<option value="0" selected="selected">{{ text_left }}</option>
														<option value="1">{{ text_right }}</option>
													{% endif %}
												</select>
											</div>
									
											<div class="input clearfix">
												<p>{{ text_submenu_width }}</p>
												<input type="text" name="submenu_width" value="{{ submenu_width }}"> <div>{{ text_example }}</div>
											</div>
									
											<div class="input clearfix">
												<p>{{ text_display_submenu_on }}</p>
												<select name="display_submenu">
													{% if display_submenu == 0 %}
														<option value="0" selected="selected">Hover</option>
													{% else %}
														<option value="0">Hover</option>
													{% endif %}
													
													{% if display_submenu == 2 %}
														<option value="2" selected="selected">Hover intent</option>
													{% else %}
														<option value="2">Hover intent</option>
													{% endif %}
													
													{% if display_submenu == 1 %}
														<option value="1" selected="selected">Click</option>
													{% else %}
														<option value="1">Click</option>
													{% endif %}
												</select>
											</div>								
										</div>
										<h4 class="button_content_config">{{ text_content_config }}</h4>({{ text_content_item }})
										<div id="text_content_config" class="collapse">
									
											<div class="input clearfix">
												<p>{{ text_content_width }}</p>
												<select name="content_width">
													{% for i in 1..12 %}
														<option value="{{ i }}" {% if i == content_width %} {{ 'selected="selected"' }} {% endif %}>{{ i }}/12</option>
													{% endfor %}
												</select>
											</div>
											
											<div class="input clearfix">
												<p>{{ text_content_type }}</p>
												<select name="content_type">
													{% if content_type != 0 %}
														<option value="0">HTML</option>
													{% else %}
														<option value="0" selected="selected">HTML</option>
													{% endif %}
													
													{% if content_type != 1 %}
														<option value="1">Product</option>
													{% else %}
														<option value="1" selected="selected">Product</option>
													{% endif %}
													
													{% if content_type != 2 %}
														<option value="2">Category</option>
													{% else %}
														<option value="2" selected="selected">Category</option>
													{% endif %}

													{% if content_type != 3 %}
														<option value="3">Manufacture</option>
													{% else %}
														<option value="3" selected="selected">Manufacture</option>
													{% endif %}
													
													{% if content_type != 4 %}
														<option value="4">Image</option>
													{% else %}
														<option value="4" selected="selected">Image</option>
													{% endif %}

													{% if content_type != 5 %}
														<option value="5">Subcategory</option>
													{% else %}
														<option value="5" selected="selected">Subcategory</option>
													{% endif %}
													{% if content_type != 6 %}
														<option value="6">Product List</option>
													{% else %}
														<option value="6" selected="selected">Product List</option>
													{% endif %}
												</select>
											</div>
											<div id="content_type0"{% if content_type != 0 %} {{ 'style="display:none"' }} {% endif %} class="content_type content_type_html">
											<h5 style="margin-top:20px">HTML</h5>
											<div class="tab-pane">
												<ul id="language" class="nav nav-tabs">
													{% for language in languages %}
														<li>
															<a data-toggle="tab" href="#content_html_{{ language.language_id }}">
																<img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" /> {{ language.name }}
															</a>
														</li>
													{% endfor %}
												</ul>
												<div class="tab-content">
													{% for language in languages %}
													{% set lang_id = language.language_id %}
													
													<div id="content_html_{{ language.language_id }}" class="content_html tab-pane">
														<textarea name="content[html][text][{{ language.language_id }}]" id="content_html_text_{{ language.language_id }}" class="form-control summernote" data-toggle="summernote">{{ content['html']['text'][lang_id] ? content['html']['text'][lang_id] : '' }}</textarea>
													</div>
													{% endfor %}
												</div>
											</div>
										</div>

										<div id="content_type1" {% if content_type != 1 %} {{ 'style="display:none"' }} {% endif %} class="content_type">							
											<div class="input clearfix">
												<p>Products:<br><span style="font-size:11px;color:#808080">(Autocomplete)</span></p>
												<input type="hidden" name="content[product][id]" value="{{ content.product.id }}" />
												<input type="text" id="product_autocomplete" name="content[product][name]" value="{{ content.product.name }}">
											</div>
										</div>

										<div id="content_type3" {% if content_type != 3 %} {{ 'style="display:none"' }} {% endif %} class="content_type">
											<div class="input clearfix">
												<p>Manufacture:<br><span style="font-size:11px;color:#808080">(Autocomplete)</span></p>
												<input type="text" id="manufacture_autocomplete" name="manufacture_autocomplete" value="">
												<div id="product-category" class="well well-sm" style="height: 150px; overflow: auto;">
													{% if content['manufacture']['id'] %}
														{% for key, id_category in content.manufacture.id %}
															<div id="product-category{{ id_category }}"><i class="fa fa-minus-circle"></i> {{ content.manufacture.name[key] }}
															  	<input type="hidden" name="content[manufacture][name][]" value="{{ content.manufacture.name[key] }}" />
															  	<input type="hidden" name="content[manufacture][id][]" value="{{ id_category }}" />
															</div>
														{% endfor %}
													{% endif %}
												</div>
											</div>
										</div>

										<div id="content_type4" {% if content_type != 4 %} {{ 'style="display:none"' }} {% endif %} class="content_type">
											<div class="input clearfix">
												<p>Image:</p>
												<a href="" id="thumb-image-content" data-toggle="image" class="img-thumbnail"><img src="{{ content.image.image_link ? content.image.image_link : src_image_default }}" alt="" title="" data-placeholder="{{ placeholder }}"  /></a>
												<input type="hidden" name="content[image][link]" value="{{ content.image.link ? content.image.link : image_default }}" id="input-image-content" />
											</div>
											<div class="input clearfix" >
												<p>Show Title</p>
												<select name="content[image][show_title]">
													{% if content.image.show_title == 1 and content.image.show_title %}
														<option value="1">Yes</option>
													{% else %}
														<option value="1" selected="selected">Yes</option>
													{% endif %}

													{% if content.image.show_title != 0 and content.image.show_title %}
														<option value="0">No</option>
													{% else %}
														<option value="0" selected="selected">No</option>
													{% endif %}
												</select>
											</div>
										</div>

										<div id="content_type5" {% if content_type != 5 %} {{ 'style="display:none"' }} {% endif %} class="content_type">
											<div class="input clearfix">
												<p>Category</p>
												<select  multiple name="content[subcategory][category][]" style="height: 200px;width:200px">
												  	<option value="" {% if content.subcategory.category != '' and content.subcategory.category[0] == "" %} {{ 'selected' }} {% endif %}>{{ text_all_categories }}</option>
												  	{% for category in categories %}
												  		<option value="{{ category.category_id }}" {% if content.subcategory.category != '' and category.category_id in content.subcategory.category %} {{ 'selected' }} {% endif %}>{{ category.name }}</option>
												  	{% endfor %}
												</select>
											</div>
											<div class="input clearfix">
												<p>Limit Level 1</p>
												<input type="text" name="content[subcategory][limit_level_1]" value="{{ content.subcategory.limit_level_1 ? content.subcategory.limit_level_1 : '' }}">
											</div>
											<div class="input clearfix">
												<p>Limit Level 2</p>
												<input type="text" name="content[subcategory][limit_level_2]" value="{{ content.subcategory.limit_level_2 ? content.subcategory.limit_level_2 : '' }}">
											</div>
											<div class="input clearfix">
												<p>Limit Level 3</p>
												<input type="text" name="content[subcategory][limit_level_3]" value="{{ content.subcategory.limit_level_3 ? content.subcategory.limit_level_3 : '' }}">
											</div>												
											<div class="input clearfix">
												<p>Show Title</p>
												<select name="content[subcategory][show_title]">
													{% if content.subcategory.show_title != 1 %}
														<option value="1">Yes</option>
													{% else %}
														<option value="1" selected="selected">Yes</option>
													{% endif %}

													{% if content.subcategory.show_title != 0 %}
														<option value="0">No</option>
													{% else %}
														<option value="0" selected="selected">No</option>
													{% endif %}
												</select>
											</div>
											<div class="input clearfix">
												<p>Show Image</p>
												<select name="content[subcategory][show_image]">
													{% if content.subcategory.show_image != 1 %}
														<option value="1">Yes</option>
													{% else %}
														<option value="1" selected="selected">Yes</option>
													{% endif %}
													
													{% if content.subcategory.show_image != 0 %}
														<option value="0">No</option>
													{% else %}
														<option value="0" selected="selected">No</option>
													{% endif %}
												</select>
											</div>
		                                    
		                                    <div class="input clearfix">
		                                        <p>Columns</p>
		                                        <select name="content[subcategory][columns]">
		                                            {% if content.subcategory.columns != 1 %}
		                                            	<option value="1">1</option>
		                                            {% else %}
		                                            	<option value="1" selected="selected">1</option>
		                                            {% endif %}
		                                            
		                                            {% if content.subcategory.columns != 2 %}
		                                            	<option value="2">2</option>
		                                            {% else %}
		                                            	<option value="2" selected="selected">2</option>
		                                            {% endif %}

		                                            {% if content.subcategory.columns != 3 %}
		                                            	<option value="3">3</option>
		                                            {% else %}
		                                            	<option value="3" selected="selected">3</option>
		                                            {% endif %}

		                                            {% if content.subcategory.columns != 4 %}
		                                            	<option value="4">4</option>
		                                            {% else %}
		                                            	<option value="4" selected="selected">4</option>
		                                            {% endif %}

		                                            {% if content.subcategory.columns != 5 %}
		                                            	<option value="5">5</option>
		                                            {% else %}
		                                            	<option value="5" selected="selected">5</option>
		                                            {% endif %}

		                                            {% if content.subcategory.columns != 6 %}
		                                            	<option value="6">6</option>
		                                            {% else %}
		                                            	<option value="6" selected="selected">6</option>
		                                            {% endif %}
		                                        </select>
		                                    </div>

		                                    
		                                    <div class="input clearfix" id="submenu-type">
		                                        <p>Submenu type</p>
		                                        <select name="content[subcategory][submenu]">
													{% if content.subcategory.submenu != 1 %}
														<option value="1">Hover</option>
													{% else %}
														<option value="1" selected="selected">Hover</option>
													{% endif %}

													{% if content.subcategory.submenu != 2 %}
														<option value="2">Visible</option>
													{% else %}
														<option value="2" selected="selected">Visible</option>
													{% endif %}
		                                        </select>
		                                    </div>

		                                    <div class="input clearfix" {% if content.subcategory.submenu != 2 %} {{ 'style="display:none"' }} {% endif %} id="submenu-columns">
		                                    	<p>Submenu columns</p>
												<select name="content[subcategory][submenu_columns]">
													{% if content.subcategory.submenu_columns != 1 %}
														<option value="1">1</option>
													{% else %}
														<option value="1" selected="selected">1</option>
													{% endif %}

													{% if content.subcategory.submenu_columns != 2 %}
														<option value="2">2</option>
													{% else %}
														<option value="2" selected="selected">2</option>
													{% endif %}

													{% if content.subcategory.submenu_columns != 3 %}
														<option value="3">3</option>
													{% else %}
														<option value="3" selected="selected">3</option>
													{% endif %}

													{% if content.subcategory.submenu_columns != 4 %}
														<option value="4">4</option>
													{% else %}
														<option value="4" selected="selected">4</option>
													{% endif %}

													{% if content.subcategory.submenu_columns != 5 %}
														<option value="5">5</option>
													{% else %}
														<option value="5" selected="selected">5</option>
													{% endif %}

													{% if content.subcategory.submenu_columns != 6 %}
														<option value="6">6</option>
													{% else %}
														<option value="6" selected="selected">6</option>
													{% endif %}
												</select>
											</div>
										</div>

										<div id="content_type6" {% if content_type != 6 %} {{ 'style="display:none"' }} {% endif %} class="content_type">
											<div class="input clearfix">
												<p>Limit</p>
												<input type="text" name="content[productlist][limit]" value="{{ content.productlist.limit ? content.productlist.limit : '' }}">
											</div>
											<div class="input clearfix">
												<p>Type</p>
												<select name="content[productlist][type]">
													{% if content.productlist.type != 'new' %}
														<option value="new">New</option>
													{% else %}
														<option value="new" selected="selected">New</option>
													{% endif %}

													{% if content.productlist.type != 'special' %}
														<option value="special">Special</option>
													{% else %}
														<option value="special" selected="selected">Special</option>
													{% endif %}

													{% if content.productlist.type != 'bestseller' %}
														<option value="bestseller">Best Seller</option>
													{% else %}
														<option value="bestseller" selected="selected">Best Seller</option>
													{% endif %}

													{% if content.productlist.type != 'popular' %}
														<option value="popular">Popular</option>
													{% endif %}
														<option value="popular" selected="selected">Popular</option>
													<?php } ?>
												</select>
											</div>
											<div class="input clearfix">
												<p>Show Title</p>
												<select name="content[productlist][show_title]">
													{% if content.productlist.show_title != 1 %}
														<option value="1">Yes</option>
													{% else %}
														<option value="1" selected="selected">Yes</option>
													{% endif %}

													{% if content.productlist.show_title != 0 %}
														<option value="0">No</option>
													{% else %}
														<option value="0" selected="selected">No</option>
													{% endif %}
												</select>
											</div>
		                                    
		                                    <div class="input clearfix">
		                                        <p>Columns</p>
		                                        <select name="content[productlist][col]">
		                                            {% if content.productlist.col != 1 %}
		                                            	<option value="1">1</option>
		                                            {% else %}
		                                            	<option value="1" selected="selected">1</option>
		                                            {% endif %}

		                                            {% if content.productlist.col != 2 %}
		                                            	<option value="2">2</option>
		                                            {% else %}
		                                            	<option value="2" selected="selected">2</option>
		                                            {% endif %}

		                                            {% if content.productlist.col != 3 %}
		                                            	<option value="3">3</option>
		                                            {% else %}
		                                            	<option value="3" selected="selected">3</option>
		                                            {% endif %}

		                                            {% if content.productlist.col != 4 %}
		                                            	<option value="4">4</option>
		                                            {% else %}
		                                            	<option value="4" selected="selected">4</option>
		                                            {% endif %}

		                                            {% if content.productlist.col != 5 %}
		                                            	<option value="5">5</option>
		                                            {% else %}
		                                            	<option value="5" selected="selected">5</option>
		                                            {% endif %}

		                                            {% if content.productlist.col != 6 %}
		                                            	<option value="6">6</option>
		                                            {% else %}
		                                            	<option value="6" selected="selected">6</option>
		                                            {% endif %}
		                                        </select>
		                                    </div>                                        
										</div>

		                                <div id="content_type2" {% if content_type != 2 %} {{ 'style="display:none"' }} {% endif %} class="content_type">
		                                    <h5 style="margin-top:20px">Categories</h5>
		                                    <div class="input clearfix">
		                                        <p>Add categories<br><span style="font-size:11px;color:#808080">(Autocomplete)</span></p>
		                                        <input type="text" id="categories_autocomplete" value="">
		                                    </div>
		                                    <div class="input clearfix">
		                                        <p>Sort categories</p>
		                                        <div class="cf nestable-lists">
		                                            <div class="dd" id="sort_categories">
		                                                <ol class="dd-list">
		                                                    {{ list_categories }}
		                                                </ol>
		                                            </div>
		                                            <input type="hidden" id="sort_categories_data" name="content[categories][categories]" value="{{ content.categories.categories is iterable ? '' : content.categories.categories }}" />
		                                        </div>
		                                    </div>
		                                    
		                                    <div class="input clearfix">
		                                        <p>Columns</p>
		                                        <select name="content[categories][columns]">
		                                            {% if content.categories.columns != 1 %}
		                                            	<option value="1">1</option>
		                                            {% else %}
		                                            	<option value="1" selected="selected">1</option>
		                                            {% endif %}

		                                            {% if content.categories.columns != 2 %}
		                                            	<option value="2">2</option>
		                                            {% else %}
		                                            	<option value="2" selected="selected">2</option>
		                                            {% endif %}

		                                            {% if content.categories.columns != 3 %}
		                                            	<option value="3">3</option>
		                                            {% else %}
		                                            <option value="3" selected="selected">3</option>
		                                            {% endif %}

		                                            {% if content.categories.columns != 4 %}
		                                            	<option value="4">4</option>
		                                            {% else %}
		                                            	<option value="4" selected="selected">4</option>
		                                            {% endif %}

		                                            {% if content.categories.columns != 5 %}
		                                            	<option value="5">5</option>
		                                            {% else %}
		                                            	<option value="5" selected="selected">5</option>
		                                            {% endif %}

		                                            {% if content.categories.columns != 6 %}
		                                            	<option value="6">6</option>
		                                            {% else %}
		                                            	<option value="6" selected="selected">6</option>
		                                            {% endif %}
		                                        </select>
		                                    </div>

		                                    <div class="input clearfix" id="submenu-type">
		                                        <p>Submenu type</p>
		                                        <select name="content[categories][submenu]">
													{% if content.categories.submenu != 1 %}
														<option value="1">Hover</option>
													{% else %}
														<option value="1" selected="selected">Hover</option>
													{% endif %}

													{% if content.categories.submenu != 2 %}
														<option value="2">Visible</option>
													{% else %}
														<option value="2" selected="selected">Visible</option>
													{% endif %}
		                                        </select>
		                                    </div>

		                                    <div class="input clearfix" {% if content.categories.submenu != 2 %} {{ 'style="display:none"' }} {% endif %} id="submenu-columns">
		                                    	<p>Submenu columns</p>
		                                    	<select name="content[categories][submenu_columns]">
		                                            {% if content.categories.submenu_columns != 1 %}
		                                            	<option value="1">1</option>
		                                            {% else %}
		                                            	<option value="1" selected="selected">1</option>
		                                            {% endif %}

		                                            {% if content.categories.submenu_columns != 2 %}
		                                            	<option value="2">2</option>
		                                            {% else %}
		                                            	<option value="2" selected="selected">2</option>
		                                            {% endif %}

		                                            {% if content.categories.submenu_columns != 3 %}
		                                            	<option value="3">3</option>
		                                            {% else %}
		                                            	<option value="3" selected="selected">3</option>
		                                            {% endif %}

		                                            {% if content.categories.submenu_columns != 4 %}
		                                            	<option value="4">4</option>
		                                            {% else %}
		                                            	<option value="4" selected="selected">4</option>
		                                            {% endif %}

		                                            {% if content.categories.submenu_columns != 5 %}
		                                            	<option value="5">5</option>
		                                            {% else %}
		                                            	<option value="5" selected="selected">5</option>
		                                            {% endif %}

		                                            {% if content.categories.submenu_columns != 6 %}
		                                            	<option value="6">6</option>
		                                            {% else %}
		                                            	<option value="6" selected="selected">6</option>
		                                            {% endif %}
		                                    	</select>
		                            		</div>
		                    			</div>
									</div>
								</div>
		    				{% else %}
		    					<div class="right col-md-8 col-xs-12 col-sm-6">
									<div class="buttons clearfix">
										<button type="submit" name="button-close" class="button-save" value="" title="Close"><i class="fa fa-reply"></i></button>
										<button type="submit" name="button-save" class="button-save" value="" title="Save"><i class="fa fa-floppy-o"></i></button>
									</div>
		    
									<input type="hidden" name="moduleid" value="{{ moduleid }}" />
		    						<h4><p>{{ text_basic_configuration }}</p></h4>
			
									{% if module_id %}
										<div class="input clearfix">
											<p>Import Module</p>
											<select name="import_module">
												{% if modules %}
													<option value="0">No Import</option>
													{% for module in modules %}
														<option value="{{ module.module_id }}">{{ module.name }}</option>
													 {% endfor %}
												{% endif %}
											</select>
										</div>
									{% endif %}
		    
							        <div class="input clearfix">
						                <p>{{ text_name }}</p>
						                <input type="text" name="name" value="{{ name }}"  id="input-name" class="form-control" />
							        </div>
			
									<div class="input clearfix">
										<p>{{ entry_head_name }}</p>
										{% set i = 0 %}
										{% for language in languages %}
											{% set i = i + 1 %}
											<input type="text" name="head_name[{{ language.language_id }}]" placeholder="{{ entry_head_name }}" id="input-headname-{{ language.language_id }}" value="{{ head_name[language.language_id] ? head_name[language.language_id] : '' }}" class="form-control {{ i>1 ? ' hide ' : ' first-name' }}" />
										{% endfor %}
										<select  class="form-control" id="head_name_language">
											{% for language in languages %}
												<option value="{{ language.language_id }}"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" /> {{ language.name }}</option>
											{% endfor %}
										</select>
									</div>

									<div class="input clearfix">
										<p>{{ entry_display_title_module }}</p>
										<select name="disp_title_module" id="input-disp_title_module" class="form-control">
											{% if disp_title_module %}
												<option value="1" selected="selected">{{ text_yes }}</option>
												<option value="0">{{ text_no }}</option>
											{% else %}
												<option value="1">{{ text_yes }}</option>
												<option value="0" selected="selected">{{ text_no }}</option>
											{% endif %}
										</select>
									</div>
			
							        <div class="input clearfix">
						                <p>{{ text_status }}</p>
						                <select name="status">
					                        {% if status %}
						                        <option value="1" selected="selected">{{ text_enabled }}</option>
						                        <option value="0">{{ text_disabled }}</option>
					                        {% else %}
						                        <option value="1">{{ text_enabled }}</option>
						                        <option value="0" selected="selected">{{ text_disabled }}</option>
					                        {% endif %}
						                </select>
							        </div>
			
							        <div class="input clearfix">
						                <p>{{ text_use_cache }}</p>
						                <label class="radio-inline">
					                        {% if use_cache %}
					                        	<input type="radio" name="use_cache" value="1" checked="checked" />
					                        	{{ text_yes }}
					                        {% else %}
					                        	<input type="radio" name="use_cache" value="1" />
					                        	{{ text_yes }}
					                        {% endif %}
						                </label>
						                <label class="radio-inline">
					                        {% if use_cache %}
					                        	<input type="radio" name="use_cache" value="0" />				                        	
					                        	{{ text_no }}
					                        {% else %}
					                        	<input type="radio" name="use_cache" value="0" checked="checked" />
					                        	{{ text_no }}
					                        {% endif %}
						                </label>
							        </div>
		    
							        <div class="input clearfix" id="input-cache_time_form">
							                <p>{{ text_cache_time }}</p>
							                <input type="text" name="cache_time" value="{{ cache_time }}"  id="input-name" class="form-control" />
							        </div>
		    
			        				<h4 style="margin-top:20px">{{ text_design_configuration }}</h4>        
							        <div class="input clearfix">
						                <p>{{ text_orientation }}</p>
						                <select name="orientation">
					                        {% if orientation %}
					                        	<option value="0">Horizontal</option>
					                        	<option value="1" selected="selected">Vertical</option>
					                        {% else %}
						                        <option value="0" selected="selected">Horizontal</option>
						                        <option value="1">Vertical</option>
					                        {% endif %}
						                </select>
							        </div>
							        
							        <div class="input clearfix">
						                <p>{{ text_number_load_vertical }}</p>
						                <input type="text" name="show_itemver" value="{{ show_itemver }}"  id="input-name" class="form-control" />
							        </div>
			
									<div class="input clearfix">
										<p>{{ text_navigation_text }}</p>
										{% set i = 0 %}
										{% for language in languages %}
											{% set i = i + 1 %}
											<input type="text" name="navigation_text[{{ language.language_id }}]" placeholder="{{ text_navigation_text }}" id="input-text-navigation-{{ language.language_id }}" value="{% if navigation_text[language.language_id] %} {{ navigation_text[language.language_id] }} {% endif %}" class="form-control {{ i>1 ? ' hide ' : ' first-name' }}" />
										{% endfor %}
										<select class="form-control" id="navigation_language">
											{% for language in languages %}
												<option value="{{ language.language_id }}"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" /> {{ language.name }}</option>
											{% endfor %}
										</select>
									</div>
		    
							        <div class="input clearfix">
						                <p>{{ text_expand_menu_bar }}</p>
						                <select name="full_width">
					                        {% if full_width %}
						                        <option value="1" selected="selected">Yes</option>
						                        <option value="0">No</option>
					                        {% else %}
						                        <option value="1">Yes</option>
						                        <option value="0" selected="selected">No</option>
					                        {% endif %}
						                </select>
							        </div>
		    
							        <div class="input clearfix">
						                <p>{{ text_home_item }}</p>
						                <select name="home_item">
					                        {% if home_item == 'icon' %}
					                        	<option value="icon" selected="selected">Icon</option>
					                        {% else %}
					                        	<option value="icon">Icon</option>
					                        {% endif %}
					                        
					                        {% if home_item == 'text' %}
					                        	<option value="text" selected="selected">Text</option>
					                        {% else %}
					                        	<option value="text">Text</option>
					                        {% endif %}

					                        {% if home_item == 'disabled' %}
					                        	<option value="disabled" selected="selected">Disabled</option>
					                        {% else %}
					                        	<option value="disabled">Disabled</option>
					                        {% endif %}
						                </select>
							        </div>
			
									<div class="input clearfix">
										<p>{{ text_home_text }}</p>
										{% set i = 0 %}
										{% for language in languages %}
											{% set i = i + 1 %}
										 	<input type="text" name="home_text[{{ language.language_id }}]" placeholder="{{ text_home_text }}" id="input-home-text-{{ language.language_id }}" value="{% if home_text[language.language_id] %} {{ home_text[language.language_id] }} {% endif %}" class="form-control {{ i>1 ? ' hide ' : ' first-name' }}" />
										{% endfor %}
										<select  class="form-control" id="home_text_language">
											{% for language in languages %}
												<option value="{{ language.language_id }}"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}" /> {{ language.name }}</option>
											{% endfor %}
										</select>
									</div>        

		    						<h4 style="margin-top:20px">{{ text_jquery_animations }}</h4>        
							        <div class="input clearfix">
						                <p>{{ text_animation }}</p>
						                <div>
					                        <input type="radio" value="slide" name="animation" {% if animation == 'slide' %} {{ 'checked' }} {% endif %}> Slide<br>
					                        <input type="radio" value="fade" name="animation" {% if animation == 'fade' %} {{ 'checked' }} {% endif %}> Fade<br>
					                        <input type="radio" value="none" name="animation" {% if animation == 'none' %} {{ 'checked' }} {% endif %}> None
						                </div>
							        </div>
		    
							        <div class="input clearfix">
						                <p>{{ text_animation_time }}</p>
						                <input type="text" name="animation_time" style="width:50px;margin-right:10px" value="{{ animation_time }}">
						                <div>ms</div>
							        </div>
								</div>
							{% endif %}
						</div>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>

<script type="text/javascript">
    $('#language a:first').tab('show');
    if($("input[name='use_cache']:radio:checked").val() == '0')
    {
        $('#input-cache_time_form').hide();
    }else
    {
        $('#input-cache_time_form').show();
    }
        
    $("input[name='use_cache']").change(function(){
        val = $(this).val();
        if(val ==0)
        {
            $('#input-cache_time_form').hide();
        }else
        {
           $('#input-cache_time_form').show();
        }
    });

    jQuery(document).ready(function($) {
		$(".button_parent_config").click(function(){
			if($(this).hasClass('active'))
				$(this).removeClass('active');
			else
				$(this).addClass('active');

			$("#text_parent_config").collapse('toggle');
		});

		$(".button_content_config").click(function(){
			if($(this).hasClass('active'))
				$(this).removeClass('active');
			else
				$(this).addClass('active');
			$("#text_content_config").collapse('toggle');
		});

        $('#nestable-menu').on('click', function(e)
        {
			var target = $(e.target),
					action = target.data('action');
			if (action === 'expand-all') {
					$('.dd').nestable('expandAll');
			}
			if (action === 'collapse-all') {
					$('.dd').nestable('collapseAll');
			}
        });

		$('#language').change(function(){
			var that = $(this), opt_select = $('option:selected', that).val() , _input = $('#input-head-name-'+opt_select);
			$('[id^="input-head-name-"]').addClass('hide');
			_input.removeClass('hide');
		});

		$('#head_name_language').change(function(){
			var that = $(this), opt_select = $('option:selected', that).val() , _input = $('#input-headname-'+opt_select);
			$('[id^="input-headname-"]').addClass('hide');
			_input.removeClass('hide');
		});

		$('#des_language').change(function(){
			var that = $(this), opt_select = $('option:selected', that).val() , _input = $('#input-head-des-'+opt_select);
			$('[id^="input-head-des-"]').addClass('hide');
			_input.removeClass('hide');
		});

		$('#navigation_language').change(function(){
			var that = $(this), opt_select = $('option:selected', that).val() , _input = $('#input-text-navigation-'+opt_select);
			$('[id^="input-text-navigation-"]').addClass('hide');
			_input.removeClass('hide');
		});

		$('#home_text_language').change(function(){
			var that = $(this), opt_select = $('option:selected', that).val() , _input = $('#input-home-text-'+opt_select);
			$('[id^="input-home-text-"]').addClass('hide');
			_input.removeClass('hide');
		});

        $("select[name=content_type]").change(function () {
            $("select[name=content_type] option:selected").each(function() {
                $(".content_type").hide();
                $("#content_type" + $(this).val()).show();
            });
        });
        $("#submenu-type").change(function () {
            $("#submenu-type option:selected").each(function() {
                if($(this).val() == 2) {
                    $("#submenu-columns").show();
                } else {
                    $("#submenu-columns").hide();
                }
            });
        });

		$('li','.content_type_html').first().addClass('active');
		$('.tab-pane','.content_type_html .tab-content').first().addClass('active');
        $(".type_link").change(function () {
            $(".type_link option:selected").each(function() {
                if($(this).val() == 1) {
					$(".type_link_url").hide();
					$(".type_link_category").show();
                } else {
					$(".type_link_category").hide();
					$(".type_link_url").show();
                }
            });
        });

        $('#product_autocomplete').autocomplete({
            delay: 500,
            source: function(request, response) {
                $.ajax({
                    url: 'index.php?route=catalog/product/autocomplete&user_token={{ user_token }}&filter_name=' + encodeURIComponent(request) ,
                    dataType: 'json',
                    success: function(json) {
                        json.unshift({
                            'product_id':  0,
                            'name':  'None'
                        });
                        response($.map(json, function(item) {
                            return {
                             	label: item.name,
                             	value: item.product_id
                            }
                        }));
                    }
                });
            },
            select: function(event) {
                $('#product_autocomplete').val(event.label);
                $('input[name=\'content[product][id]\']').val(event.value);
                return false;
            },
            focus: function(event) {
                return false;
            }
        });

		// Manufacturer
		$('input[name=\'manufacture_autocomplete\']').autocomplete({
			'source': function(request, response) {
				$.ajax({
					url: 'index.php?route=catalog/manufacturer/autocomplete&user_token={{ user_token }}&filter_name=' +  encodeURIComponent(request),
					dataType: 'json',
					success: function(json) {
						response($.map(json, function(item) {
							return {
								label: item['name'],
								value: item['manufacturer_id']
							}
						}));
					}
				});
			},
			'select': function(item) {
				$('input[name=\'category\']').val('');

				$('#product-category' + item['value']).remove();

				$('#product-category').append('<div id="product-category' + item['value'] + '"><i class="fa fa-minus-circle"></i> ' + item['label'] + '<input type="hidden" name="content[manufacture][id][]" value="' + item['value'] + '" /><input type="hidden" name="content[manufacture][name][]" value="' + item['label'] + '" /></div>');
			}
		});

		$('#product-category').delegate('.fa-minus-circle', 'click', function() {
			$(this).parent().remove();
		});


        $('#categories_autocomplete').autocomplete({
            delay: 500,
            source: function(request, response) {
                $.ajax({
                    url: 'index.php?route=catalog/category/autocomplete&user_token={{ user_token }}&filter_name=' +  request,
                    dataType: 'json',
                    success: function(json) {
                            json.unshift({
                                'category_id':  0,
                                'name':  'None'
                            });
                            response($.map(json, function(item) {
                                return {
                                    label: item.name,
                                    value: item.category_id
                                }
                            }));
                    }
                });
            },
            select: function(event) {
                if(event.value > 0) {
                    $("#sort_categories > .dd-list").append('<li class="dd-item" data-id="' + event.value + '" data-name="' + event.label + '"><a class="fa fa-times"></a><div class="dd-handle">' + event.label + '</div></li>');
                }
                updateOutput2($('#sort_categories').data('output', $('#sort_categories_data')));
				$( "#sort_categories .fa-times" ).on( "click", function() {
					$(this).parent().remove();
					updateOutput2($('#sort_categories').data('output', $('#sort_categories_data')));
				});
                return false;
            },
            focus: function(event) {
                return false;
            }
        });

        function lagXHRobjekt() {
            var XHRobjekt = null;

            try {
                ajaxRequest = new XMLHttpRequest(); // Firefox, Opera, ...
            } catch(err1) {
                try {
                    ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); // Noen IE v.
                } catch(err2) {
                    try {
                        ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); // Noen IE v.
                    } catch(err3) {
                        ajaxRequest = false;
                    }
                }
            }
            return ajaxRequest;
        }


        function menu_updatesort(jsonstring) {
            mittXHRobjekt = lagXHRobjekt();

            if (mittXHRobjekt) {
                mittXHRobjekt.onreadystatechange = function() {
                    if(ajaxRequest.readyState == 4){
                        var ajaxDisplay = document.getElementById('sortDBfeedback');
                        ajaxDisplay.innerHTML = ajaxRequest.responseText;
                    }
                }
                ajaxRequest.open("GET", "index.php?route=extension/module/megamenu&user_token={{ user_token }}&jsonstring=" + encodeURIComponent(jsonstring), true);
                ajaxRequest.setRequestHeader("Content-Type", "application/json");
                ajaxRequest.send(null);
            }
        }

        var updateOutput = function(e)
        {
            var list   = e.length ? e : $(e.target),
                output = list.data('output');

            if (window.JSON) {
                menu_updatesort(window.JSON.stringify(list.nestable('serialize')));
            } else {
                alert('JSON browser support required for this demo.');
            }
        };

        $('#nestable').nestable({
                group: 1,
                maxDepth: 4
        }).on('change', updateOutput);

        updateOutput($('#nestable').data('output', $('#nestable-output')));

        var updateOutput2 = function(e)
        {
            var list   = e.length ? e : $(e.target),
                output = list.data('output');
            if (window.JSON && typeof(output)!= 'undefined' ) {
                output.val(window.JSON.stringify(list.nestable('serialize')));
            }
        };

        $('#sort_categories').nestable({
               group: 1,
                maxDepth: 5
        }).on('change', updateOutput2);

        updateOutput2($('#sort_categories').data('output', $('#sort_categories_data')));

       $( "#sort_categories .fa-times" ).on( "click", function() {
               $(this).parent().remove();
               updateOutput2($('#sort_categories').data('output', $('#sort_categories_data')));
       });
                
        ///cache
        var button = '<div class="remove-caching" style="margin-left: 15px"><button type="button" onclick="remove_cache()" title="{{ button_clear_cache }}" class="btn btn-danger"><i class="fa fa-remove"></i> {{ button_clear_cache }}</button></div>';
        var button_min = '<div class="remove-caching" style="margin-left: 7px"><button type="button" onclick="remove_cache()" title="{{ button_clear_cache }}" class="btn btn-danger"><i class="fa fa-remove"></i> </button></div>';
        
        if($('#column-left').hasClass('active')){
            $('#column-left #stats').after(button);
        }else{
            $('#column-left #stats').after(button_min);
        }

        $('#button-menu').click(function(){
            $('.remove-caching').remove();
            if($(this).parents().find('#column-left').hasClass('active')){
                $('#column-left #stats').after(button);
            }else{
                $('#column-left #stats').after(button_min);
            }
        });
    });
        
    function remove_cache(){
        var success_remove = '{{ success_remove }}';
        $.ajax({
            type: 'POST',
            url: '{{ linkremove }}',
            data: {	is_ajax_cache_lite: 1},
            success: function () {
                var html = '<div class="alert alert-success cls-remove-cache" style="margin: 5px 25px"> '+success_remove+' <button type="button" class="close" data-dismiss="alert">&times;</button></div>';
                if(!($('.page-header .container-fluid .alert-success')).hasClass('cls-remove-cache')){
                    $(html).insertAfter('.page-header .container-fluid');
                }
            },
        });
    }
</script>
<script type="text/javascript" src="view/javascript/summernote/summernote.js"></script>
<link href="view/javascript/summernote/summernote.css" rel="stylesheet" />
<script type="text/javascript" src="view/javascript/summernote/summernote-image-attributes.js"></script>
<script type="text/javascript" src="view/javascript/summernote/opencart.js"></script>
{{ footer }}